﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;

public partial class Views_Employees : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            LoadInformation_Detailt();
        }
    }

    protected void ToolbarShowHelp_DirectClick(object sender, Ext.Net.DirectEventArgs e)
    {
        Response.Redirect("Help.aspx");
    }

    protected void LoadInformation_Detailt()
    {
        try
        {
            using (ManagerEmployeesEntities db = new ManagerEmployeesEntities())
            {
                int empID = Int32.Parse(Request.QueryString["emp"].ToString());

                Employee employee = db.Employees.Single(e => e.EmpID == empID);

                LabelCodeEmp.Text = employee.Code;
                LabelOrganManager.Text = employee.Department.Organization.NameOfOrgan;
                LabelOrganUsing.Text = employee.Department.Organization.NameOfOrgan;

                ImageAvata.ImageUrl = "Avatars/" + employee.AvatarUrl;
                LabelFullName.Text = (employee.FirstName + " " + employee.LastName).ToUpper();
                LabelOtherName.Text = employee.NameOther;
                LabelDay.Text = employee.DateOfBirth.Value.Day.ToString();
                LabelMonth.Text = employee.DateOfBirth.Value.Month.ToString();
                LabelYear.Text = employee.DateOfBirth.Value.Year.ToString();
                LabelGender.Text = Boolean.Parse(employee.Gender.Value.ToString()) ? "Nam" : "Nữ";
                LablePlaceOfBirth.Text = employee.PlaceOfBirth;
                LabelHomeTown.Text = employee.HomeTown;


                LabelEthnic.Text = employee.Ethnic;
                LabelReligion.Text = employee.Religion;
                LabelHouseHold.Text = employee.HouseHold;
                LabelCurrentAddress.Text = employee.CurrentAddress;


                LabelJobCurrent.Text = employee.JobCurrent;
                LabelDateOfRecruitment.Text = DateTime.Parse(employee.DateOfRecruitment.ToString()).ToString("dd/MM/yyyy");
                LabelOrganOfRecruitment.Text = employee.OrganOfRecruitment;

                LabelCurrentPostion.Text = employee.Postion.NameOfPost;
                LabelTaskIsAssigned.Text = employee.TaskIsAssigned;
            }
        }
        catch (Exception)
        {
            X.Msg.Alert("Hệ thống thông báo", "Hệ thống đang bận, hãy quay lại sau.");
        }
    }
}